package com.restaurant.serviceimpl;

import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.restaurant.domain.Employeeattendace;
import com.restaurant.service.EmployeeattendaceService;

public class EmployeeattendaceServiceImpl implements EmployeeattendaceService {

   private HibernateTemplate hibernateTemplate;

   @Autowired
   public void setSessionFactory(SessionFactory sessionFactory){
       this.hibernateTemplate = new HibernateTemplate(sessionFactory);
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Employeeattendace addOrModify( Employeeattendace objEmployeeattendace ) {
       return ( Employeeattendace ) hibernateTemplate.merge( objEmployeeattendace );
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Employeeattendace deleteRecord( Employeeattendace objEmployeeattendace ) {
       hibernateTemplate.delete( objEmployeeattendace );
       return objEmployeeattendace;
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Employeeattendace modifyRecord( Employeeattendace objEmployeeattendace ) {
       return ( Employeeattendace ) hibernateTemplate.merge( objEmployeeattendace );
   }

   @SuppressWarnings("unchecked")
   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public List<Employeeattendace> loadAll() {
       return (List<Employeeattendace>)hibernateTemplate.findByNamedQuery( "Employeeattendace.findAll");
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Employeeattendace loadByPrimaryKey( Long primaryKey ) {
       return (Employeeattendace) hibernateTemplate.get( Employeeattendace.class, primaryKey );
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Employeeattendace deleteByPrimaryKey( Long primaryKey ) {
       return deleteRecord(loadByPrimaryKey(primaryKey));
   }

   @SuppressWarnings("unchecked")
   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public List<Employeeattendace> loadByHql(String query) {
       return ( List<Employeeattendace> ) hibernateTemplate.find( query );
   }
}